package com.btcode.web.core.filter;

import java.util.HashMap;
import javax.servlet.Filter;

public class WebFilter<T extends Filter> {

    private String path;

    private Class<T> filter;

    private Filter filterInstance;

    private HashMap<String, String> initParams;

    public WebFilter(String path, Class<T> filter, HashMap<String, String> initParams) {
        this.path = path;
        this.filter = filter;
        this.initParams = initParams;
    }

    public WebFilter(String path, T filter, HashMap<String, String> initParams) {
        this.path = path;
        this.filterInstance = filter;
        this.initParams = initParams;
    }

    public HashMap<String, String> getInitParams() {
        return initParams;
    }

    public void setInitParams(HashMap<String, String> initParams) {
        this.initParams = initParams;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Class<T> getFilter() {
        return filter;
    }

    public void setFilter(Class<T> filter) {
        this.filter = filter;
    }

    /**
     * 如果这个非null，则优先使用这个，否则调用getFilter
     */
    public Filter getFilterInstance() {
        return filterInstance;
    }

    public void setFilterInstance(Filter filterInstance) {
        this.filterInstance = filterInstance;
    }

}